<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="PatientListForm">

        <p:panel header="#{myBundle.ListPatientTitle}">

            <p:dataTable id="datalist" value="#{patientController.items}" var="item"
                         selectionMode="single" selection="#{patientController.selected}"
                         rowKey="#{item.pid}"
                         paginator="true"
                         rows="10"
                         rowsPerPageTemplate="10,20,30"
                         >

                <p:ajax event="rowSelect"   update="createButton viewButton editButton deleteButton"/>
                <p:ajax event="rowUnselect" update="createButton viewButton editButton deleteButton"/>

                <p:column sortBy="#{item.pid}" filterBy="#{item.pid}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPatientTitle_pid}"/>
                    </f:facet>
                    <h:outputText value="#{item.pid}"/>
                </p:column>
                <p:column sortBy="#{item.cnic}" filterBy="#{item.cnic}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPatientTitle_cnic}"/>
                    </f:facet>
                    <h:outputText value="#{item.cnic}"/>
                </p:column>
                <p:column sortBy="#{item.fname}" filterBy="#{item.fname}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPatientTitle_fname}"/>
                    </f:facet>
                    <h:outputText value="#{item.fname}"/>
                </p:column>
                <p:column sortBy="#{item.lname}" filterBy="#{item.lname}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPatientTitle_lname}"/>
                    </f:facet>
                    <h:outputText value="#{item.lname}"/>
                </p:column>
                <p:column sortBy="#{item.careOf}" filterBy="#{item.careOf}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPatientTitle_careOf}"/>
                    </f:facet>
                    <h:outputText value="#{item.careOf}"/>
                </p:column>
                <p:column sortBy="#{item.gender}" filterBy="#{item.gender}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPatientTitle_gender}"/>
                    </f:facet>
                    <h:outputText value="#{item.gender}"/>
                </p:column>
                <p:column sortBy="#{item.dob}" filterBy="#{item.dob}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPatientTitle_dob}"/>
                    </f:facet>
                    <h:outputText value="#{item.dob}">
                        <f:convertDateTime pattern="MM/dd/yyyy" />
                    </h:outputText>
                </p:column>
                <p:column sortBy="#{item.hno}" filterBy="#{item.hno}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPatientTitle_hno}"/>
                    </f:facet>
                    <h:outputText value="#{item.hno}"/>
                </p:column>
                <p:column sortBy="#{item.street}" filterBy="#{item.street}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPatientTitle_street}"/>
                    </f:facet>
                    <h:outputText value="#{item.street}"/>
                </p:column>
                <p:column sortBy="#{item.town}" filterBy="#{item.town}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPatientTitle_town}"/>
                    </f:facet>
                    <h:outputText value="#{item.town}"/>
                </p:column>
                <p:column sortBy="#{item.city}" filterBy="#{item.city}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPatientTitle_city}"/>
                    </f:facet>
                    <h:outputText value="#{item.city}"/>
                </p:column>
                <p:column sortBy="#{item.contact}" filterBy="#{item.contact}">
                    <f:facet name="header">
                        <h:outputText value="#{myBundle.ListPatientTitle_contact}"/>
                    </f:facet>
                    <h:outputText value="#{item.contact}"/>
                </p:column>
                <f:facet name="footer">
                    <p:commandButton id="createButton" icon="ui-icon-plus"   value="#{myBundle.Create}" actionListener="#{patientController.prepareCreate}" update=":PatientCreateForm" oncomplete="PatientCreateDialog.show()"/>
                    <p:commandButton id="viewButton"   icon="ui-icon-search" value="#{myBundle.View}" update=":PatientViewForm" oncomplete="PatientViewDialog.show()" disabled="#{empty patientController.selected}"/>
                    <p:commandButton id="editButton"   icon="ui-icon-pencil" value="#{myBundle.Edit}" update=":PatientEditForm" oncomplete="PatientEditDialog.show()" disabled="#{empty patientController.selected}"/>
                    <p:commandButton id="deleteButton" icon="ui-icon-trash"  value="#{myBundle.Delete}" actionListener="#{patientController.delete}" update=":growl,datalist" disabled="#{empty patientController.selected}"/>
                </f:facet>

            </p:dataTable>

        </p:panel>

    </h:form>

</ui:composition>